{\rtf1\ansi\ansicpg936\cocoartf1187\cocoasubrtf390
{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;\f1\fnil\fcharset0 Menlo-Bold;\f2\fnil\fcharset134 STHeitiSC-Light;
\f3\fnil\fcharset0 LucidaGrande;\f4\fmodern\fcharset0 Courier;}
{\colortbl;\red255\green255\blue255;\red170\green13\blue145;\red46\green58\blue89;\red39\green78\blue192;
\red83\green83\blue83;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid1\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid1}
{\list\listtemplateid2\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid101\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid2}
{\list\listtemplateid3\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid201\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid3}
{\list\listtemplateid4\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid301\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid4}
{\list\listtemplateid5\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid401\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid5}
{\list\listtemplateid6\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid501\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid6}
{\list\listtemplateid7\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid601\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid7}
{\list\listtemplateid8\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid701\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid8}
{\list\listtemplateid9\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid801\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid9}
{\list\listtemplateid10\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid901\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid10}
{\list\listtemplateid11\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1001\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid11}
{\list\listtemplateid12\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1101\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid12}
{\list\listtemplateid13\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1201\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid13}
{\list\listtemplateid14\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1301\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid14}
{\list\listtemplateid15\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1401\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid15}
{\list\listtemplateid16\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1501\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid16}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}{\listoverride\listid3\listoverridecount0\ls3}{\listoverride\listid4\listoverridecount0\ls4}{\listoverride\listid5\listoverridecount0\ls5}{\listoverride\listid6\listoverridecount0\ls6}{\listoverride\listid7\listoverridecount0\ls7}{\listoverride\listid8\listoverridecount0\ls8}{\listoverride\listid9\listoverridecount0\ls9}{\listoverride\listid10\listoverridecount0\ls10}{\listoverride\listid11\listoverridecount0\ls11}{\listoverride\listid12\listoverridecount0\ls12}{\listoverride\listid13\listoverridecount0\ls13}{\listoverride\listid14\listoverridecount0\ls14}{\listoverride\listid15\listoverridecount0\ls15}{\listoverride\listid16\listoverridecount0\ls16}}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\deftab640
\pard\tx640\pardeftab640\pardirnatural

\f0\fs28 \cf2 \CocoaLigature0 SurveyItem Hierarchy\cf0 \
\cf2 @dynamic\cf0  title;\
\cf2 @dynamic\cf0  type;\
\cf2 @dynamic\cf0  value1;\
\cf2 @dynamic\cf0  value2;\
\cf2 @dynamic\cf0  owner;\
\cf2 @dynamic\cf0  result;\
\
\cf2 Result Hierarchy\cf0 \
\cf2 @dynamic\cf0  text;\
\
\pard\tx640\pardeftab640\pardirnatural

\f1\b \cf0 \CocoaLigature1 Binary:\
\pard\tx640\pardeftab640\pardirnatural

\f0\b0 \cf0 \CocoaLigature0 S:\
\pard\tx220\tx720\pardeftab640\li720\fi-720\pardirnatural
\ls1\ilvl0\cf0 \CocoaLigature1 {\listtext	1.	}\CocoaLigature0 segmentedControl -> value1, value2\
\pard\tx640\pardeftab640\pardirnatural
\cf0 \
R:0=value1, 1=value2\
\
\pard\tx640\pardeftab640\pardirnatural

\f1\b \cf0 \CocoaLigature1 TextOnly:\
\pard\tx640\pardeftab640\pardirnatural

\f0\b0 \cf0 \CocoaLigature0 S:\
\pard\tx220\tx720\pardeftab640\li720\fi-720\pardirnatural
\ls2\ilvl0\cf0 \CocoaLigature1 {\listtext	1.	}Label -> \CocoaLigature0 value1\
\pard\tx640\pardeftab640\pardirnatural
\cf0 \
R:nil\
\
\pard\tx640\pardeftab640\pardirnatural

\f1\b \cf0 \CocoaLigature1 TextField:\
\pard\tx640\pardeftab640\pardirnatural

\f0\b0 \cf0 \CocoaLigature0 S:\
\pard\tx220\tx720\pardeftab640\li720\fi-720\pardirnatural
\ls3\ilvl0\cf0 \CocoaLigature1 {\listtext	1.	}\CocoaLigature0 subtitle -> value1\
\pard\tx640\pardeftab640\pardirnatural
\cf0 \
R:textField\
\
\pard\tx640\pardeftab640\pardirnatural

\f1\b \cf0 \CocoaLigature1 DatePicker:\
\pard\tx640\pardeftab640\pardirnatural

\f0\b0 \cf0 \CocoaLigature0 S:\
\pard\tx220\tx720\pardeftab640\li720\fi-720\pardirnatural
\ls4\ilvl0\cf0 \CocoaLigature1 {\listtext	1.	}\CocoaLigature0 nil\
\pard\tx640\pardeftab640\pardirnatural
\cf0 \
R:date\
\
\pard\tx640\pardeftab640\pardirnatural

\f1\b \cf0 \CocoaLigature1 Slider:\
\pard\tx640\pardeftab640\pardirnatural

\f0\b0 \cf0 \CocoaLigature0 S:\
\pard\tx220\tx720\pardeftab640\li720\fi-720\pardirnatural
\ls5\ilvl0\cf0 \CocoaLigature1 {\listtext	1.	}\CocoaLigature0 slider -> [value1, value2]\
\ls5\ilvl0\CocoaLigature1 {\listtext	2.	}round to int -> value3(T for rounding/F)\CocoaLigature0 \
\pard\tx640\pardeftab640\pardirnatural
\cf0 \
R:text=value\
\
\pard\tx640\pardeftab640\pardirnatural

\f1\b \cf0 \CocoaLigature1 Picker:\
\pard\tx640\pardeftab640\pardirnatural

\f0\b0 \cf0 \CocoaLigature0 S:\
\pard\tx220\tx720\pardeftab640\li720\fi-720\pardirnatural
\ls6\ilvl0\cf0 \CocoaLigature1 {\listtext	1.	}\CocoaLigature0 slider -> NSArray[value1 [
\f2 \'bc\'e4\'b8\'f4\'b7\'fb
\f0 ] value2]\
\pard\tx640\pardeftab640\pardirnatural
\cf0 \
R:text=date\
\
\pard\tx640\pardeftab640\pardirnatural

\f1\b \cf0 \CocoaLigature1 MultiTF:\
\pard\tx640\pardeftab640\pardirnatural

\f0\b0 \cf0 \CocoaLigature0 S:\
\pard\tx220\tx720\pardeftab640\li720\fi-720\pardirnatural
\ls7\ilvl0\cf0 \CocoaLigature1 {\listtext	1.	}\CocoaLigature0 slider -> NSArray[value1 [
\f2 \'bc\'e4\'b8\'f4\'b7\'fb
\f0 ] value2]\
\pard\tx640\pardeftab640\pardirnatural
\cf0 \
R:BOOL(T/F)*4\
\
\
\
\pard\pardeftab720\sa400

\f3\fs48 \cf3 \CocoaLigature1 Using Core Data with iCloud\
\pard\pardeftab720\sa200

\fs26 \cf0 When you create an application that uses Core Data and iCloud, there are two orthogonal choices you need to make:\
\pard\tx220\tx720\pardeftab720\li720\fi-720
\ls8\ilvl0\cf0 {\listtext	1.	}What sort of application do you want to create?\
{\listtext	2.	}What store type do you want to use?\
\pard\pardeftab720\sa200
\cf0 There are broadly speaking two types of Core Data-based application that integrate with iCloud:\
\pard\tx220\tx720\pardeftab720\li720\fi-720
\ls9\ilvl0\cf0 {\listtext	1.	}Library-style applications, where the application usually has a single persistent store, and data from the store is used throughout the application. Examples of this style of application are Music and Photos. \
{\listtext	2.	}Document-based applications, where different documents may be opened at different times during the lifetime of the application. Examples of this style of application are Keynote and Numbers. \
\pard\pardeftab720\sa200
\cf0 If you\'92re already using Core Data in iOS, then you probably have a library-style application. For this, you are encouraged to use the SQLite store with Core Data\'92s iCloud integration.\
UIKit provides support for document-based applications that use Core Data through the {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIManagedDocument_Class/Reference/Reference.html#//apple_ref/occ/cl/UIManagedDocument"}}{\fldrslt 
\f4 \cf4 UIManagedDocument}} class\'97a concrete subclass of the {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDocument_Class/UIDocument/UIDocument.html#//apple_ref/occ/cl/UIDocument"}}{\fldrslt 
\f4 \cf4 UIDocument}} class that represents a document. For library-style applications, you generally set up the Core Data stack as you would if you were not using iCloud. For both library-style and document-based applications, however, you must appropriately configure the persistent store(s).\
How you configure the store depends on what type of store you want to use. There are two store types to choose from:\
\pard\tx220\tx720\pardeftab720\li720\fi-720
\ls10\ilvl0\cf0 {\listtext	1.	}SQLite.\
{\listtext	2.	}Atomic (the binary store type) or a custom atomic store derived from {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/NSAtomicStore_class/Reference/NSAtomicStore.html#//apple_ref/occ/cl/NSAtomicStore"}}{\fldrslt 
\f4 \cf4 NSAtomicStore}}.\
\pard\pardeftab720\sa400

\fs48 \cf3 Use the SQLite Store for Large Datasets and Fine-Grained Change Notification\
\pard\pardeftab720\sa200

\fs26 \cf0 You usually use the SQLite store, because it offers efficient per-record change propagation and corresponding change notifications.\
In iOS 5, Core Data includes enhancements to support efficient integration of the SQLite store with iCloud. The principal new feature is that each change you commit to a persistent store is recorded in discrete transaction log files that are stored in iCloud, rather than keeping the persistent store file in the cloud directly. This means that change propagation through iCloud is efficient (the alternative would be to push the whole SQLite file for each change). There are a few consequences to this, though:\
\pard\tx220\tx720\pardeftab720\li720\fi-720
\ls11\ilvl0\cf0 {\listtext	\'95	}You must tell Core Data where to store the transaction logs associated with changes to the store. You do this by providing values for the {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSPersistentStoreCoordinator_Class/NSPersistentStoreCoordinator.html#//apple_ref/c/data/NSPersistentStoreUbiquitousContentNameKey"}}{\fldrslt 
\f4 \cf4 NSPersistentStoreUbiquitousContentNameKey}} and {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSPersistentStoreCoordinator_Class/NSPersistentStoreCoordinator.html#//apple_ref/c/data/NSPersistentStoreUbiquitousContentURLKey"}}{\fldrslt 
\f4 \cf4 NSPersistentStoreUbiquitousContentURLKey}} keys when configuring a store. The content name is used to identify the store across different devices so that transactions are synced consistently with the potentially many instances of that persistent store file across all the devices. For this reason, you must make sure you provide a unique name for each store\'97for example, a UUID. \
{\listtext	\'95	}When you remove a store from iCloud (either to make local to the device, or to delete it completely), you must delete the corresponding transaction logs directory. You do this as a coordinated operation using 
\f4 \cf5 NSFileManager
\f3 \cf0 . If you specified a custom and unique 
\f4 \cf5 NSPersistentStoreUbiquitousContentURLKey
\f3 \cf0 , simply deleting that directory will remove all transaction log data associated with the store; if your 
\f4 \cf5 NSPersistentStoreUbiquitousContentURLKey
\f3 \cf0  is shared, then you should only remove the 
\f4 \cf5 NSPersistentStoreUbiquitousContentNameKey
\f3 \cf0  subdirectory. \
{\listtext	\'95	}You must not store the SQLite file itself in a location where changes to it will be propagated by iCloud. This includes the entire parent directory that contains the SQLite store file. \uc0\u8232 This is discussed later in the context of application types. \
\pard\pardeftab720\sa400

\fs48 \cf3 Use the Atomic Store for Small Data Sets When Changes are \'93Wholesale\'94\
\pard\pardeftab720\sa200

\fs26 \cf0 With an atomic store, changes are not recorded in separate transaction log files. There are therefore potential performance implications because iCloud must propagate changes to the whole store file. You should usually only use an atomic store for small data sets. Moreover, instead of receiving notifications of changes to individual records and having the ability to merge these changes, you are simply told that the store has changed via the standard {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSFilePresenter_protocol/Reference/Reference.html#//apple_ref/occ/intf/NSFilePresenter"}}{\fldrslt 
\f4 \cf4 NSFilePresenter}} and (in document-based applications) {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDocument_Class/UIDocument/UIDocument.html#//apple_ref/occ/cl/UIDocument"}}{\fldrslt 
\f4 \cf4 UIDocument}} conflict resolution methods. You must then accept or reject the changes wholesale.\
If you use an atomic store, you must put the persistent store file in a location where changes to it will be propagated by iCloud. All saves and reads must be performed in a file coordination block.\
\pard\pardeftab720\sa400

\fs48 \cf3 Guidance for Library-style Applications\
\pard\pardeftab720\sa200

\fs26 \cf0 In a library style application, you usually have a single Core Data stack with a single persistent store coordinator and a single persistent store.\
\pard\pardeftab720\sa200

\b \cf0 If you use the SQLite store
\b0 , you:\
\pard\tx220\tx720\pardeftab720\li720\fi-720
\ls12\ilvl0\cf0 {\listtext	\'95	}Provide values for the 
\f4 \cf5 NSPersistentStoreUbiquitousContentNameKey
\f3 \cf0  and optionally the 
\f4 \cf5 NSPersistentStoreUbiquitousContentURLKey
\f3 \cf0  keys in the options dictionary when you add the store with {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSPersistentStoreCoordinator_Class/NSPersistentStoreCoordinator.html#//apple_ref/occ/instm/NSPersistentStoreCoordinator/addPersistentStoreWithType:configuration:URL:options:error:"}}{\fldrslt 
\f4 \cf4 addPersistentStoreWithType:configuration:URL:options:error:}}. You can choose whatever name you want; the content URL, however, must identify a directory in the ubiquity container.\
{\listtext	\'95	}You must put the store itself in the local application sandbox, or inside a directory with a 
\f4 \cf5 .nosync
\f3 \cf0  suffix in the ubiquity container.\
\pard\pardeftab720\sa200
\cf0 You can observe {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSPersistentStoreCoordinator_Class/NSPersistentStoreCoordinator.html#//apple_ref/c/data/NSPersistentStoreDidImportUbiquitousContentChangesNotification"}}{\fldrslt 
\f4 \cf4 NSPersistentStoreDidImportUbiquitousContentChangesNotification}} notifications posted by the persistent store; this allows you to react to changes on a per-record basis.\
\pard\pardeftab720\sa200

\b \cf0 If you use the atomic store
\b0 :\
\pard\tx220\tx720\pardeftab720\li720\fi-720
\ls13\ilvl0\cf0 {\listtext	\'95	}You put the store directly in the ubiquity container.\
{\listtext	\'95	}To handle changes propagated from iCloud, you implement suitable {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSFilePresenter_protocol/Reference/Reference.html#//apple_ref/occ/intf/NSFilePresenter"}}{\fldrslt 
\f4 \cf4 NSFilePresenter}} protocol methods.\
\pard\pardeftab720\sa400

\fs48 \cf3 Guidance for Document-based Applications\
\pard\pardeftab720\sa200

\fs26 \cf0 In a document-based application, you represent the document using an instance of {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIManagedDocument_Class/Reference/Reference.html#//apple_ref/occ/cl/UIManagedDocument"}}{\fldrslt 
\f4 \cf4 UIManagedDocument}}. The document instance automatically aggregates managed object models it finds in the application\'92s main bundle (subclasses can override the {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIManagedDocument_Class/Reference/Reference.html#//apple_ref/occ/instp/UIManagedDocument/managedObjectModel"}}{\fldrslt 
\f4 \cf4 managedObjectModel}} property to customize this behavior) and manages the Core Data stack for you.\
A managed document uses two managed object contexts. The first context is created on a private queue so that changes can be saved asynchronously. The second is a child of the first, created on the main queue. The child context is the context that the document returns from the {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIManagedDocument_Class/Reference/Reference.html#//apple_ref/occ/instp/UIManagedDocument/managedObjectContext"}}{\fldrslt 
\f4 \cf4 managedObjectContext}} method. This has a couple of implications:\
\pard\tx220\tx720\pardeftab720\li720\fi-720
\ls14\ilvl0\cf0 {\listtext	\'95	}If you want to register for change notifications, make sure you register for those posted by the appropriate context.\
{\listtext	\'95	}To save changes, you should usually rely on 
\f4 \cf5 UIDocument
\f3 \cf0 \'92s autosaving logic. If you want to force a save at a given point, however, you should generally not invoke the {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObjectContext_Class/NSManagedObjectContext.html#//apple_ref/occ/instm/NSManagedObjectContext/save:"}}{\fldrslt 
\f4 \cf4 save:}} method on the child context\'97this will simply propagate changes to the parent context and not actually commit them to the store. Instead, you should use 
\f4 \cf5 UIDocument
\f3 \cf0 's {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDocument_Class/UIDocument/UIDocument.html#//apple_ref/occ/instm/UIDocument/saveToURL:forSaveOperation:completionHandler:"}}{\fldrslt 
\f4 \cf4 saveToURL:forSaveOperation:completionHandler:}} method, which commits changes from the child to the parent, then from the parent to the store.\
\pard\pardeftab720\sa200
\cf0 An instance of 
\f4 \cf5 UIManagedDocument
\f3 \cf0  uses a SQLite store by default; you can specify a different store type by creating a subclass of an instance 
\f4 \cf5 UIManagedDocument
\f3 \cf0  and overriding {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIManagedDocument_Class/Reference/Reference.html#//apple_ref/occ/instm/UIManagedDocument/persistentStoreTypeForFileType:"}}{\fldrslt 
\f4 \cf4 persistentStoreTypeForFileType:}} to return the appropriate type.\
\pard\pardeftab720\sa80

\fs38 \cf0 Documents that use a SQLite store\
\pard\pardeftab720\sa200

\fs26 \cf0 If you use a SQLite store, you need to provide a unique identifier for the store. You set the identifier using the 
\f4 \cf5 NSPersistentStoreUbiquitousContentNameKey
\f3 \cf0  in the {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIManagedDocument_Class/Reference/Reference.html#//apple_ref/occ/instm/UIManagedDocument/setPersistentStoreOptions:"}}{\fldrslt 
\f4 \cf4 setPersistentStoreOptions:}} dictionary for the managed document. You should also provide a ubiquitous content URL using the 
\f4 \cf5 NSPersistentStoreUbiquitousContentURLKey
\f3 \cf0 . (The default URL is based on the bundle identifier. If you provide a custom URL for the transaction logs, you can share documents across applications with different identifiers. Typically you specify a directory called 
\f4 \cf5 TransactionLogs
\f3 \cf0  in the ubiquity container.) So that you can retrieve it later if necessary (for example, when deleting a document), 
\f4 \cf5 UIManagedDocument
\f3 \cf0  saves the store\'92s ubiquitous content name in a property list file named 
\f4 \cf5 DocumentMetadata.plist
\f3 \cf0  in the document package.\
To summarize details about the document structure and location:\
\pard\tx220\tx720\pardeftab720\li720\fi-720
\ls15\ilvl0\cf0 {\listtext	\'95	}The document package contains a property list file, 
\f4 \cf5 DocumentMetadata.plist
\f3 \cf0 .\
{\listtext	\'95	}The root element in the 
\f4 \cf5 DocumentMetadata.plist
\f3 \cf0  property list is a dictionary. One of the dictionary keys is 
\f4 \cf5 NSPersistentStoreUbiquitousContentNameKey
\f3 \cf0 . The corresponding value is the name of the directory that contains the transaction logs for the document.\
{\listtext	\'95	}Transaction logs for a document are stored in a directory: <Value of NSPersistentStoreUbiquitousContentURLKey>/<Value of NSPersistentStoreUbiquitousContentNameKey>.\
\pard\pardeftab720\sa200
\cf0 To ensure that the persistent store itself is not synced by iCloud: when you set a value for the 
\f4 \cf5 NSPersistentStoreUbiquitousContentNameKey
\f3 \cf0 , 
\f4 \cf5 UIManagedDocument
\f3 \cf0  puts the persistent store in a 
\f4 \cf5 .nosync
\f3 \cf0  directory inside the document package. If you make use of additional content (using the {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIManagedDocument_Class/Reference/Reference.html#//apple_ref/occ/instm/UIManagedDocument/writeAdditionalContent:toURL:originalContentsURL:error:"}}{\fldrslt 
\f4 \cf4 writeAdditionalContent:toURL:originalContentsURL:error:}} method), you must make sure that the document directory is not a package. Typically you give the document directory an extension that is not recognized as a document extension.\
To respond to changes propagated from iCloud, you observe {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSPersistentStoreCoordinator_Class/NSPersistentStoreCoordinator.html#//apple_ref/c/data/NSPersistentStoreDidImportUbiquitousContentChangesNotification"}}{\fldrslt 
\f4 \cf4 NSPersistentStoreDidImportUbiquitousContentChangesNotification}} notifications posted by the document's persistent store; this allows you to respond to changes on a per-record basis.\
To find documents, you use a metadata query as you would for other ubiquitous content. The query returns the 
\f4 \cf5 DocumentMetadata.plist
\f3 \cf0  file inside the document packages.\
To open a document that uses the SQLite store, you must retrieve the value of the 
\f4 \cf5 NSPersistentStoreUbiquitousContentNameKey
\f3 \cf0  from the 
\f4 \cf5 DocumentMetadata.plist
\f3 \cf0  file and set that content name key in the {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIManagedDocument_Class/Reference/Reference.html#//apple_ref/occ/instm/UIManagedDocument/persistentStoreOptions"}}{\fldrslt 
\f4 \cf4 persistentStoreOptions}} dictionary before you open the document with {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDocument_Class/UIDocument/UIDocument.html#//apple_ref/occ/instm/UIDocument/openWithCompletionHandler:"}}{\fldrslt 
\f4 \cf4 openWithCompletionHandler:}}.\
To delete a document that uses the SQLite store, you must also delete the transaction logs directory for the document. You do this as a coordinated operation using 
\f4 \cf5 NSFileManager
\f3 \cf0 .\
\pard\pardeftab720\sa400

\fs48 \cf3 Schema Migration\
\pard\pardeftab720\sa200

\fs26 \cf0 Core Data applications will not sync with other versions using different schemas. With the SQLite store, Core Data only supports lightweight migration on iCloud. When using light weight migration, different versions of the application will not sync with each other. When an older version upgrades, it will catch up and previously too-new versions will merge in the older version\'92s changes.\
Because atomic stores overwrite the entire file, if you update the schema the store will not be able to be read by clients using a previous schema.\
\pard\pardeftab720\sa400

\fs48 \cf3 Limitations on Functionality\
\pard\pardeftab720\sa200

\fs26 \cf0 When used with iCloud, there are several limitations with the SQLite store at this time:\
\pard\tx220\tx720\pardeftab720\li720\fi-720
\ls16\ilvl0\cf0 {\listtext	\'95	}Ordered relationships are not supported.\
{\listtext	\'95	}You cannot simply move or copy an existing database file to iCloud. Instead, you should use 
\f4 \cf5 NSPersistentStoreCoordinator
\f3 \cf0 's {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSPersistentStoreCoordinator_Class/NSPersistentStoreCoordinator.html#//apple_ref/occ/instm/NSPersistentStoreCoordinator/migratePersistentStore:toURL:options:withType:error:"}}{\fldrslt 
\f4 \cf4 migratePersistentStore:toURL:options:withType:error:}} method to migrate the database to the required location.\
{\listtext	\'95	}Schema migration using mapping models is not supported (lightweight migration is supported).}